package com.hxh.component.business.arouter.router;


import com.alibaba.android.arouter.launcher.ARouter;
import com.hxh.component.business.arouter.databoard.IHomeProvider;
import com.hxh.component.business.arouter.employee.IEmployeeProvider;
import com.hxh.component.business.arouter.mine.IMineProvider;
import com.hxh.component.business.arouter.parttimejob.IParttimejobProvider;
import com.hxh.component.business.arouter.recruit.IRecruitProvider;
import com.hxh.component.business.arouter.work.IWorkProvider;

/**
 * 创建者：hxh
 * 时间：  2017/8/15
 * 描述： 此类只是管理Router跳转（简便MyAppProvider操作），请将所有Provider在此初始化，供MyAppProvider调用
 *
 */
public class ServiceManager {

    private IWorkProvider mIWorkProvider;
    private IHomeProvider mIHomeProvider;
    private IEmployeeProvider mIEmployeeProvider;
    private IRecruitProvider mIRecruitProvider;
    private IParttimejobProvider mIParttimejobProvider;
    private IMineProvider mIMineProvider;

    //region 单利
    public ServiceManager() {
        ARouter.getInstance().inject(this);
    }

    private static final class ServiceManagerHolder {
        private static final ServiceManager instance = new ServiceManager();
    }

    public static ServiceManager getInstance() {
        return ServiceManagerHolder.instance;
    }
    //endregion

    public IWorkProvider getWorkProvider() {
        return mIWorkProvider != null ? mIWorkProvider : (mIWorkProvider = ((IWorkProvider) MyRouter.newInstance(IWorkProvider.WORK_SERVICE).navigation()));
    }

    public IWorkProvider getContractProvider() {
        return mIWorkProvider != null ? mIWorkProvider : (mIWorkProvider = ((IWorkProvider) MyRouter.newInstance(IWorkProvider.WORK_SERVICE).navigation()));
    }

    public IHomeProvider getHomeProvider() {
        return mIHomeProvider != null ? mIHomeProvider : (mIHomeProvider = ((IHomeProvider) MyRouter.newInstance(IHomeProvider.DATABOARD_SERVICE).navigation()));
    }

    public IEmployeeProvider getEmployeeProvider() {
        return mIEmployeeProvider != null ? mIEmployeeProvider : (mIEmployeeProvider = ((IEmployeeProvider) MyRouter.newInstance(IEmployeeProvider.EMPLOYEE_SERVICE).navigation()));
    }

    public IRecruitProvider getRecruitProvider() {
        return mIRecruitProvider != null ? mIRecruitProvider : (mIRecruitProvider = ((IRecruitProvider) MyRouter.newInstance(IRecruitProvider.RECRUIT_SERVICE).navigation()));
    }

    public IParttimejobProvider getParttimejobProvider() {
        return mIParttimejobProvider != null ? mIParttimejobProvider : (mIParttimejobProvider = ((IParttimejobProvider) MyRouter.newInstance(IParttimejobProvider.PARTTIMEJOB_SERVICE).navigation()));
    }

    public IMineProvider getMineProvider() {
        return mIMineProvider != null ? mIMineProvider : (mIMineProvider = ((IMineProvider) MyRouter.newInstance(IMineProvider.MINE_SERVICE).navigation()));
    }
}

